Socket
Socket
Sign inDemoInstall

expand-template

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

expand-template

Expand placeholders in a template string


Version published
Weekly downloads
5.9M
increased by3.29%
Maintainers
1
Weekly downloads
 
Created

What is expand-template?

The expand-template npm package is designed for string templating. It allows users to interpolate variables within a string template, making it useful for generating dynamic strings based on variable inputs. This can be particularly useful in applications that require dynamic generation of content, configuration files, or code snippets based on user input or application state.

What are expand-template's main functionalities?

Variable Interpolation

This feature allows the user to interpolate variables within a string template. The example demonstrates how to use the expand-template package to replace the {{name}} placeholder with the string 'World'.

`const expand = require('expand-template')({open: '{{', close: '}}'});
let template = 'Hello, {{name}}!';
let result = expand({name: 'World'});
console.log(result); // Outputs: Hello, World!`

Custom Delimiters

This feature enables the use of custom delimiters for the template placeholders. In the provided code, the delimiters are set to '<<' and '>>', and the example shows how to replace the <<year>> placeholder with 2023.

`const expand = require('expand-template')({open: '<<', close: '>>'});
let template = 'Current year: <<year>>';
let result = expand({year: 2023});
console.log(result); // Outputs: Current year: 2023`

Other packages similar to expand-template

Keywords

FAQs

Package last updated on 27 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc